public class KNNnode implements Comparable<KNNnode>{

    /**
     * 实现comparable接口重写compareTo（）方法
     * 目的：方便存放KNNnode对象的List进行排序，排序的目标属性为l（即与待测点距离）
     */
    float x1,x2;  //特征值
    String type;  //特征值对应的类型
    double l ;     //与待预测点的距离

    public float getX1() {
        return x1;
    }

    public void setX1(float x1) {
        this.x1 = x1;
    }

    public float getX2() {
        return x2;
    }


    public void setX2(float x2) {
        this.x2 = x2;
    }


    public String getType() {
        return type;
    }


    public void setType(String type) {
        this.type = type;
    }


    public double getL() {
        return l;
    }


    public void setL(double l) {
        this.l = l;
    }

    @Override
    public String toString() {
        return "KNNnode [x1=" + x1 + ", x2=" + x2 + ", type=" + type + ", l="
                + l + "]";
    }
    //从小到大排列
    @Override
    public int compareTo(KNNnode o) {
        // TODO Auto-generated method stub
        if(l<o.getL())
            return -1;
        if(l>o.getL())
            return 1;
        return 0;
    }
}